package cn.maihe.elg.operation.repository.entity;

import cn.maihe.elg.operation.repository.entity.NoticeRetryInfoVo;
import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_notice_retry_info")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.NoticeRetryInfoMapper")
public class NoticeRetryInfo extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 通知类型 1开函结果通知 2理赔结果通知
     */
    @TableField(value = "notice_type")
    private Integer noticeType;

    @TableField(value = "center_id")
    private Long centerId;

    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 受理订单号
     */
    @TableField(value = "accept_order_no")
    private String acceptOrderNo;

    /**
     * 通知报文json字符串
     */
    @TableField(value = "req_body_json")
    private String reqBodyJson;

    /**
     * 通知报文反序列化类
     */
    @TableField(value = "req_body_class")
    private String reqBodyClass;

    /**
     * 响应报文json字符串
     */
    @TableField(value = "resp_body_json")
    private String respBodyJson;

    /**
     * 下次通知日期时间
     */
    @TableField(value = "next_time")
    private Date nextTime;

    /**
     * 通知重试次数
     */
    @TableField(value = "retry_times")
    private Integer retryTimes;

    public NoticeRetryInfoVo buildVo() {
        return new NoticeRetryInfoVo(id, noticeType, centerId, orgId, acceptOrderNo, reqBodyJson, reqBodyClass, respBodyJson, nextTime, retryTimes);
    }

    public static NoticeRetryInfo of(NoticeRetryInfoVo vo) {
        return new NoticeRetryInfo(vo.getId(), vo.getNoticeType(), vo.getCenterId(), vo.getOrgId(), vo.getAcceptOrderNo(), vo.getReqBodyJson(), vo.getReqBodyClass(), vo.getRespBodyJson(), vo.getNextTime(), vo.getRetryTimes());
    }
}